//
//  VC3TabBarController.swift
//  ChapterAll
//
//  Created by Kevin on 2020/4/23.
//  Copyright © 2020 Kevin. All rights reserved.
//

import UIKit

class VC3TabBarController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        var arr = Array<UIViewController>()
        for i in 0..<10 {
            let tab = UIViewController()
            tab.title = "\(i)签"
            tab.view.backgroundColor = getColor()
            tab.tabBarItem.image = UIImage(named: "ic_action_home")
            tab.tabBarItem.selectedImage = UIImage(named: "ic_action_anchor")
            arr.append(tab)
        }
        
        let tabbar = UITabBarController()
        tabbar.viewControllers = arr
        tabbar.tabBar.tintColor = UIColor.purple
        tabbar.tabBar.barTintColor = UIColor.green
        tabbar.modalPresentationStyle = .fullScreen
        present(tabbar, animated: true, completion: nil)
    }
    
    func getColor() -> UIColor {
        return UIColor.init(displayP3Red: getColorValue(), green: getColorValue(), blue: getColorValue(), alpha: 1)
    }
    
    func getColorValue() -> CGFloat {
        return CGFloat(arc4random() % 255) / 255.0
    }
}
